import { Extractor } from "../class/Extractor";
import { $$text, $attr, $text } from "../Decorators/Extractor";


export class Extractor2 extends Extractor {
    /** 书名 */
    @$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.book-name")
    title: string = '';

    /** 字数 */
    @$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.nums > span:nth-child(1) > i")
    size: string = '';

    /** 总推荐 */
    @$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.nums > span:nth-child(2) > i")
    total_recommend: string = "";

    /** 点击量 */
    @$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.nums > span:nth-child(3) > i")
    click: string = "";

    /** 周推荐 */
    @$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.nums > span:nth-child(4) > i")
    week_recommend: string = "";

    /** 书的封面 */
    @$attr("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-img.fl > img", "src")
    cover: string = ""
    @$$text("body > div.wrap > div.book-html-box.clearfix > div.book-top.clearfix > div.book-main.fl > div.book-detail.clearfix > div.book-info > div.book-label > span > a")
    tags: string[] = []


    static async saveDataHook(extrator: Extractor2) {
        console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        console.log("~~~~~~~~~~~~  爬取一本书  ~~~~~~~~~~~~~");
        console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        console.log("书名：", extrator.title);
        console.log("字数：", extrator.size);
        console.log("总推荐：", extrator.total_recommend);
        console.log("总点击：", extrator.click);
        console.log("周推荐：", extrator.week_recommend);
        console.log("封面：", extrator.cover);
        console.log("标签：", extrator.tags);

    }
}

